#====# Appendix I: Robustness to exclusion of firms #====#

# Load libraries and set defaults ----
library(bizdays)
library(modelsummary)
library(tinytable)
library(tidytext)
library(lemon)
library(tidyverse)
library(tidylog, warn.conflicts = FALSE)
source("aux/event_function.R")
source("aux/plot_theme.R")

# prepare business calendar:
business_calendar <- create.calendar('biz_calendar', weekdays = c('saturday','sunday'))

# Import data ----
stocks <- read_rds("data_out/stocks_analysis.rds") # main analysis dataset

# Table I.1: Excluding firms with poorly-estimated counterfactuals ----
length(unique(stocks$ticker_symbol[stocks$FCPA_sample == 1 & stocks$fit_R2 < 0.01])) # 33
length(unique(stocks$ticker_symbol[stocks$FCPA_sample == 0 & stocks$fit_R2 < 0.01])) # 28

est <- return_daily_avg(data = stocks %>%
                          filter(fit_R2 >= 0.01), 
                        abn_ret = "abn_chg", cum_abn_ret = "car", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Excludes firms with market models having R\\textsuperscript{2} smaller than 0.01. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Excluding firms with poorly-estimated counterfactuals \\label{tab:rob_r2}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_I1.html", overwrite = TRUE)

# Figure I.1: Jackknife test ----
jackknife_1 <- map(.x = unique(stocks$ticker_symbol[stocks$FCPA_sample == 1]),
                   .f = ~stocks %>%
                     dplyr::filter(ticker_symbol != .x) %>%
                     dplyr::filter(FCPA_sample == 1) %>%
                     dplyr::filter(date == as.Date("2025-02-10")) %>%
                     dplyr::reframe(mean = mean(abn_chg, na.rm = TRUE),
                                    se = sd(abn_chg, na.rm = TRUE)/sqrt(n())) %>%
                     dplyr::mutate(excluded = .x),
                   .progress = TRUE) %>%
  bind_rows() %>%
  # add the original estimate for comparison:
  rbind(stocks %>%
          filter(FCPA_sample == 1) %>%
          filter(date == as.Date("2025-02-10")) %>%
          reframe(mean = mean(abn_chg, na.rm = TRUE),
                  se = sd(abn_chg, na.rm = TRUE)/sqrt(n())) %>%
          mutate(excluded = "Full sample")) %>%
  mutate(conf.low = mean -1.96*se,
         conf.high = mean + 1.96*se)

jackknife_0 <- map(.x = unique(stocks$ticker_symbol[stocks$FCPA_sample == 0]),
                   .f = ~stocks %>%
                     dplyr::filter(ticker_symbol != .x) %>%
                     dplyr::filter(FCPA_sample == 0) %>%
                     dplyr::filter(date == as.Date("2025-02-10")) %>%
                     dplyr::reframe(mean = mean(abn_chg, na.rm = TRUE),
                                    se = sd(abn_chg, na.rm = TRUE)/sqrt(n())) %>%
                     dplyr::mutate(excluded = .x),
                   .progress = TRUE) %>%
  bind_rows() %>%
  # add the original estimate for comparison:
  rbind(stocks %>%
          filter(FCPA_sample == 0) %>%
          filter(date == as.Date("2025-02-10")) %>%
          reframe(mean = mean(abn_chg, na.rm = TRUE),
                  se = sd(abn_chg, na.rm = TRUE)/sqrt(n())) %>%
          mutate(excluded = "Full sample")) %>%
  mutate(conf.low = mean -1.96*se,
         conf.high = mean + 1.96*se)

jackknife_1 %>%
  mutate(FCPA_sample = 1) %>%
  rbind(jackknife_0 %>%
          mutate(FCPA_sample = 0)) %>%
  mutate(type = ifelse(excluded == "Full sample", "Full sample", "Leave-one-out"),
         FCPA_sample = fct_relevel(as.factor(FCPA_sample), "1"),
         excluded = reorder_within(excluded, -mean, FCPA_sample)) %>%
  ggplot(aes(x = mean, y = reorder(excluded, -mean))) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high, col = type, alpha = type)) +
  geom_vline(xintercept = 0, linewidth = 0.1) +
  facet_rep_wrap("FCPA_sample", nrow = 1, scales = "free_y",
                 repeat.tick.labels = "all",
                 labeller = as_labeller(c("0" = "Non-FCPA targets",
                                          "1" = "Past FCPA targets"))) +
  scale_color_manual("", values = c("red", "black")) +
  scale_alpha_manual("", values = c(1, 0.5)) +
  xlab("Average abnormal returns on Executive Order day and 95% CIs") +
  ylab("Model No.") +
  coord_cartesian(clip = "off",
                  ylim = c(-5, 265)) +
  theme(axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        legend.key.width = unit(2, "cm")) +
  guides(colour = guide_legend(override.aes = list(alpha = 1)))
ggsave("plots/figure_I1.pdf", height = 5, width = 9)

# Table I.2: Excluding 10 past FCPA targets realizing extreme gains ----
# drop the top 10 outliers with the highest returns among the treated firms
drop <- stocks %>%
  group_by(ticker_symbol) %>%
  arrange(ticker_symbol, date) %>%
  mutate(l_prccd = lag(prccd)) %>%
  filter(date == as.Date("2025-02-10")) %>%
  filter(FCPA_sample == 1) %>%
  mutate(diff = cshoq * l_prccd * abn_chg/100) %>%
  ungroup() %>%
  arrange(-diff) %>%
  filter(row_number() <= 10) %>%
  pull(ticker_symbol)
drop 
# dropped: "WMT"   "MCD"   "MSFT"  "UBER"  "XOM"   "QCOM"  "ALIZF" "ROK"   "SIEGY" "ABT"

est <- return_daily_avg(data = stocks %>%
                          filter(!ticker_symbol %in% drop), 
                        abn_ret = "abn_chg", cum_abn_ret = "car", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Excludes the top 10 past FCPA targets by gains in market capitalization on the day of the Executive Order. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Excluding 10 past FCPA targets realizing extreme gains \\label{tab:rob_excl10}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_I2.html", overwrite = TRUE)

# Table I.3: Excluding past FCPA targets that miss from matching procedure ----
keep <- stocks %>%
  filter(matched == 1) %>%
  select(ticker_symbol) %>%
  pull() %>%
  unique()

est <- return_daily_avg(data = stocks %>%
                          filter(ticker_symbol %in% keep), 
                        abn_ret = "abn_chg", cum_abn_ret = "car", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Excludes the past FCPA targets that could not be matched to placebo firms due to missing covariate information. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Excluding past FCPA targets that miss from matching procedure \\label{tab:rob_excl_match}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_I3.html", overwrite = TRUE)

# Table I.4: Excluding firms trading over-the-counter ----
est <- return_daily_avg(data = stocks %>%
                          filter(exchgn != "Other-OTC"), 
                        abn_ret = "abn_chg", cum_abn_ret = "car", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Excludes firms trading stocks over-the-counter. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Excluding firms trading over-the-counter \\label{tab:rob_excl_OTC}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_I4.html", overwrite = TRUE)

# Table I.5: Excluding past FCPA targets whose trading history we reconstructed ----
est <- return_daily_avg(data = stocks %>%
                          filter(ticker_change == 0 | FCPA_sample == 0), 
                        abn_ret = "abn_chg", cum_abn_ret = "car", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Excludes past FCPA targets whose ownership history we reconstructed. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Excluding past FCPA targets whose trading history we reconstructed \\label{tab:rob_excl_ticker_change}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_I5.html", overwrite = TRUE)

#====# The End #====#